<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>Example</title>
</head>

<body>
  <p>
    <button id="scroll">Scroll</button>
    <button id="print">Print</button>
    <button id="close">Close</button>
  </p>
  <p>
    There are lots of different kind of fruit.
  </p>

  <script type="text/javascript">
var buttons = document.getElementsByTagName('button');
for (var i = 0; i < buttons.length; i++) {
  buttons[i].onclick = handleButtonPress;
}

function handleButtonPress(e) {
  if (e.target.id == "print") {
    window.print();
  }
  else if (e.target.id == "close") {
    window.close();
  }
  else {
    window.scrollTo(0, 400);
  }
}
  </script>
</body>

</html>
